package eight.test_8_7;

import java.util.Scanner;

public class TestMain2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int count = n;
        for (int i = 1; i < m; i++) {
            count *= (n - 1);
            count %= 109;
        }
        System.out.println(count);
    }
}
